#include <stdio.h>
#include <stdlib.h>
#include <GL/gl.h>
#include "vertex_processor.h"
#include "assembler.h"
#include "raster.h"
#include "gcg.h"

float Z_BUFFER*;

void sqsFrameBuffer(unsigned int width,unsigned int height){
    Z_BUFFER = (float*) malloc(width * height * sizeof(float));
    createImage(width,height,32,true);
}

void sqsClear(VECTOR4* background){
    int i;
    glClear(background);

    for (i = 0; i < Z_BUFFER->width * Z_BUFFER->height; i++) {
        Z_BUFFER[i] = -1.0;
    }
}

void sqsOutputFragment(int x, int y){
}

void sqsLineBresenham(int x0,int y0,int x1,int y1){

    int dx = fabs(x1 - x0);
    int dy = fabs(y1 - y0);
    int p = 2 * (dy - dx);
    int dy2 = 2 * dy;
    int dxdy2 = 2 * (dx - dy);
    int x,y,xend;

    if(x0 > x1){
        x = x1;
        y = y1;
        xend = x0;
    }else {
        x = x0;
        y = y0;
        xend = x1;
    }
    sqsOutputFragment(x,y);

    while(x < xend){
        x++;
        if(p < 0){
            p = p + dy2;
        }else{
            y++;
            p = p + dxdy2;
        }
        sqsOutputFragment(x,y);
    }
}



char sqsDepthTeste(struct FRAGMENT* f){
    return 0;
}

void sqsRasterPoint(struct INTERNAL_VERTEX* v){
}

void sqsRasterLine(struct INTERNAL_VERTEX* v1,struct INTERNAL_VERTEX *v2){

}

void sqsRasterTriangle(struct INTERNAL_VERTEX *v1,struct INTERNAL_VERTEX *v2,struct INTERNAL_VERTEX *v3){
}
